package com.hibase.upms.controller;


import com.hibase.common.entity.ResponseModel;
import com.hibase.common.util.EntityUtil;
import com.hibase.core.web.annotation.HibasePostRequestMapping;
import com.hibase.upms.entity.rolemenu.MdsRoleMenu;
import com.hibase.upms.entity.rolemenu.vo.MdsDataPermIdVO;
import com.hibase.upms.entity.rolemenu.vo.MdsViewDataPermVO;
import com.hibase.upms.service.rolemenu.MdsRoleMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ChrisCui
 * @since 2019-04-19
 */
@RestController
@RequestMapping("/mds-role-menu")
@Api(tags = "角色-菜单管理")
public class MdsRoleMenuController {

    @Autowired
    private MdsRoleMenuService roleMenuService;

//    @ApiOperation(value = "设置数据权限", httpMethod = "POST")
//    @HibasePostRequestMapping(value = "/settingDataPerm")
//    public ResponseModel<String> settingDataPerm(@RequestBody MdsDataPermVO dataPermVO) {
//
//        return super.successMsg(roleMenuService.settingDataPerm(dataPermVO));
//    }

    @ApiOperation(value = "查看数据权限", httpMethod = "POST")
    @HibasePostRequestMapping(value = "/viewDataPerm")
    public ResponseModel<MdsViewDataPermVO> viewDataPerm(@RequestBody MdsDataPermIdVO dataPermIdVO) {

        MdsRoleMenu roleMenu = this.roleMenuService.selectMdsRoleMenu(dataPermIdVO.getMenuId(), dataPermIdVO.getRoleId());

        return ResponseModel.successMsg(EntityUtil.transform(roleMenu, MdsViewDataPermVO.class));
    }
}
